<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=\, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //JSON表示方法
      //1.单值（值不能是undefined）
      var productName = "牙膏";
      var price = 9.99;

      //2.对象（对象中的key可以不加引号，也可以是单或双引号，如果键中有空格和其他符号，必须用引号引起来。值如果是字符型，用加单引号或双引号，其他类型不加引号）
      var data = {
        pId: "000001", //键值对
        pName: "矿泉水",
        price: 1.0,
      };
      //3.数组(字符型的值要用单/双引号引起来，其他类型的值不加引号)
      var data2 = [10, 30, "abc", true, null];
      //4.复杂数据
      var students = [
        {
          no: "8254025",
          name: "张三",
          age: 18,
          tel: 2131242142,
          score: [78, 90, 99],
        },
        {
          no: "8254025",
          name: "李四",
          age: 19,
          tel: 4351242142,
          score: [98, 60, 99],
        },
        {
          no: "8254025",
          name: "王五",
          age: 20,
          tel: 6547548754142,
          score: [68, 80, 99],
        },
      ];

      var cities = {
        errorCode: 0,
        data: [
          {
            prov: "北京市",
            cities: ["北京市"],
          },
          {
            prov: "广东省",
            cities: ["广州市", "深圳市", "东莞市"],
          },
        ],
      };
    </script>
  </body>
</html>
